package com.xishu.dao.jpa;

import com.xishu.entity.shop.FoodTable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;

public interface FoodTableDao extends JpaRepository<FoodTable, Long>, JpaSpecificationExecutor<FoodTable> {

    /**
     * 删除临时开的餐桌
     *
     * @param shopId
     */
    @Modifying
    @Transactional
    @Query("update food_table set flagDelete=true where shopId=:shopId and template=false")
    public void flagDeleteNonTemplateFoodTable(long shopId);


    /**
     * 更新模板状态
     *
     * @param shopId
     * @param status
     * @param template
     */
    @Modifying
    @Transactional
    @Query("update  food_table set status = :status  where shopId=:shopId and template=:template")
    public void updateTemplateFoodTable(Long shopId, Integer status, Boolean template);

}
